<?php
/**
 * 咨询加盟通知邮件
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/5/28 14:52
 * @copyright PanxSoft Inc.
 */

namespace App\Services\Mailer;

use App\Http\Models\Feedback;
use Carbon\Carbon;
use Illuminate\Mail\Mailer;
use Illuminate\Mail\Message;

class ConsultJoinMail
{
    const VIEW_EMAIL_CONSULT_JOIN = 'email.consult-join';

    /**
     * @test
     *
     * @param string $email
     * @param Feedback $feedback
     */
    public static function send ($email, Feedback $feedback)
    {
        /** @var Mailer $mailer */
        $mailer = app('mailer');

        $mailer->send(self::VIEW_EMAIL_CONSULT_JOIN, compact('feedback'),
            function (Message $msg) use ($email) {
                $msg->subject('魔发科技代理加盟咨询：' . Carbon::now());
                /**
                 * 此处 from address 如果使用 qq 邮箱必须与 .env 中 MAIL_USERNAME 一致
                 */
                $msg->from(config('mail.username'), 'Magic Hair');
                $msg->to($email);
            });
    }
}